package com.example.administrator.newsapp.DialogManagers;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.example.administrator.newsapp.R;

public class AddNewsDialog {
    private Dialog mDialog;
    private Context mContext;
    public AddNewsDialog(Context context){
        mContext=context;
    }

    public void showmenu(){
        mDialog=new Dialog(mContext,R.style.AddNews);
        LayoutInflater inflater=LayoutInflater.from(mContext);
        View view=inflater.inflate(R.layout.activity_addnews,null);
        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDialog.dismiss();
            }
        });
        view.findViewById(R.id.close_direct).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDialog.dismiss();
            }
        });
        mDialog.setContentView(view);
        mDialog.setCanceledOnTouchOutside(true);
        Window window=mDialog.getWindow();
        window.setWindowAnimations(R.style.editdialogAnimation);
        window.setGravity(Gravity.CENTER_VERTICAL);
        WindowManager.LayoutParams layoutParams=window.getAttributes();
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.y=750;
        window.setAttributes(layoutParams);

        mDialog.show();
    }


}
